home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / newsgroups / misc.20041116-20060924 / 000117_fdc@columbia.edu_Fri Jun 24 10:10:24 2005.msg < prev    next >
Internet Message Format  |  2006-09-27  |  3KB

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: Iterating Through a Dialing Directory
  5. Date: 24 Jun 2005 14:09:12 GMT
  6. Organization: Columbia University
  7. Lines: 51
  8. Message-ID: <slrndbo508.6l8.fdc@sesame.cc.columbia.edu>
  9. References: <1119556401.918892.120180@g14g2000cwa.googlegroups.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1119622152 17679 128.59.59.56 (24 Jun 2005 14:09:12 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 24 Jun 2005 14:09:12 GMT
  15. User-Agent: slrn/0.9.8.0 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15358
  17.  
  18. On 2005-06-23, Allen <amtekdesign@gmail.com> wrote:
  19. : I'm trying to use Kermit 95 on a WinXP host to modem dial a group of
  20. : point-of-sale devices. I'd like to set up the phone numbers in a
  21. : dialing directory and then have a script loop through the directory,
  22. : calling each device and downloading sales data, until each device has
  23. : been polled. It seems like there should be an easy way to do this, but
  24. : I can't find anything short of using normal file I/O to scan the
  25. : directory file, pull out each name, and give it to the dial command.
  26. :
  27. Right, there is no built-in function to step through a dialing directory.
  28. I would say that the way you are doing it is appropriate, but I also think
  29. it would be good if Kermit had a programmatic way to access the
  30. dialing-directory filename list, and also programmatic access to its own
  31. functions for reading the entries (stripping comments and whatnot); I'll
  32. add these to my list.  Meanwhile, here's a short script that reads and
  33. parses a dialing directory file.  It accounts for {Entry Names Containing
  34. Spaces}, blank lines, comment lines, and trailing comments:
  35.  
  36.   #!/usr/local/bin/kermit +
  37.   if not def \%1 exit 1 "Usage: \%0 dialing-directory-filename"
  38.  
  39.   fopen /read \%c \fcontents(\%1)         # Open the file
  40.   if fail exit 1
  41.  
  42.   define parse {                          # Parse dialing directory entry
  43.       .name := \%1                        # Entry name
  44.       shift                               # Shift past name
  45.       .number := \%*                      # Phone number is the rest
  46.       .\%9 := \findex(\32;,\m(number))    # Strip any trailing comment
  47.       if \%9 .number := \ftrim(\s(number[1:\%9]))
  48.   }
  49.   .\%n = 0                                # Entry counter
  50.  
  51.   while true {
  52.       fread /line \%c line                # Read a line
  53.       if fail break                       # End of file
  54.       .line := \ftrim(\fltrim(\m(line)))  # Remove any surrounding spaces
  55.       if not def line continue            # Skip blank lines
  56.       if eq "\s(line[1:1])" ";" continue  # Skip comment lines
  57.       if eq "\s(line[1:1])" "#" continue  # Ditto
  58.       parse \m(line)                      # Parse and count the entry
  59.       incr \%n    
  60.       echo "\%n. [\m(name)] = [\m(number)]"
  61.   }
  62.   fclose \%c
  63.   exit 0 "Records: \%n"
  64.  
  65. Replace the ECHO command with a call to any macro or script file that
  66. you want to make the call and do the work.
  67.  
  68. - Frank